/**
 * 将所有模块加载至this对象
 */
function define(moduleName:string|Function, require:string[], func:Function) {

    if (moduleName instanceof Function) {
        (moduleName as Function)();
        return;
    }

    /**
     * 给模块名添加"_1"后缀
     */
    var getModuleName = function (module:string) {
        var pos = module.lastIndexOf("/")
        if (pos >= 0) {
            return module.substr(pos + 1) + "_1";
        }
        return module + "_1";
    }

    var newName = getModuleName(<string>moduleName);
    if (!this[newName])
        this[newName] = {};

    require[1] = this[newName];

    for (var i = 2; i < require.length; i++) {
        var reqName = getModuleName(require[i]);
        if (!this[reqName])
            this[reqName] = {};
        require[i] = this[reqName];
    }
    func.apply(this, require);

    //加载两次模块
    var module = this[newName];
    for (var mod in module) {
        if (!this[mod]) {
            this[mod] = module[mod];
        }
    }
}